﻿[assembly: System.Web.UI.WebResource("BM.Tools.WebControls.MForm.Controls.ValueHandlers.ValueHandler.js", "application/x-javascript")]
[assembly: System.Web.UI.WebResource("BM.Tools.WebControls.MForm.Controls.ValueHandlers.ValueHandler.debug.js", "application/x-javascript")]

namespace BM.Tools.WebControls.MForm.Controls.ValueHandlers
{    
    using System.ComponentModel;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    using AjaxControlToolkit;

    using BM.Tools.WebControls.MForm.Controls.Items;
    using BM.Tools.WebControls.MForm.Design;

    /// <summary>
    /// A value handler is a control that can be used to bind the <see cref="LeafItem" /> control with controls that may be used ot get or set values
    /// </summary>
    [ClientScriptResource("BM.Tools.WebControls.MForm",
            "BM.Tools.WebControls.MForm.Controls.ValueHandlers.ValueHandler.js", LoadOrder = 0)]
    [ParseChildren(true)]
    [Designer(typeof(ValueHandlerDesigner))]
    public abstract class ValueHandler : CompositeControl
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ValueHandler"/> class.
        /// </summary>
        protected ValueHandler()
        {
            SetId();
        }

        /// <summary>
        /// Gets or sets Value.
        /// </summary>
        public abstract string Value
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets ID.
        /// </summary>
        public override string ID
        {
            get
            {
                return base.ID;
            }

            set
            {                
            }
        }

        /// <summary>
        /// Gets Owner.
        /// </summary>
        /// <value>
        /// The owner.
        /// </value>
        protected LeafItem Owner
        {
            get
            {
                return Parent.Parent as LeafItem;
            }
        }

        /// <summary>
        /// Does not render anything.
        /// </summary>
        /// <param name="writer">
        /// The writer.
        /// </param>
        public override void RenderBeginTag(HtmlTextWriter writer)
        {
        }

        /// <summary>
        /// Does not render anything.
        /// </summary>
        /// <param name="writer">
        /// The writer.
        /// </param>
        public override void RenderEndTag(HtmlTextWriter writer)
        {
        }

        private void SetId()
        {
            base.ID = "VH";
        }

        private bool ShouldSerializeID()
        {
            return false;
        }
    }
}